//
//  RCNetwork.h
//  RCC_Project
//
//  Created by liwenbo on 16/3/16.
//  Copyright © 2016年 liwenbo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"

/**
 请求方法枚举
 */
typedef enum {
    GET,
    POST,
    POSTPHOTO,
    PATCH,
    DELETE
}HTTPMethod ;

/**
 *  请求成功回调
 *
 *  @param dic 服务器返回的数据
 */
typedef void (^requestSuccessBlock)(NSDictionary *dic);

/**
 *  请求失败的回调
 *
 *  @param error 错误信息
 */
typedef void (^requestFailureBlock)(NSError *error);

@interface YONetwork : NSObject


/**
 *  GET 请求
 *
 *  @param url     网络请求的 url
 *  @param params  网络请求 参数
 *  @param success 请求成功的回调
 *  @param failure 请求失败的回调
 */
+ (void)getWithURL:(NSString *)url
        withParams:(NSDictionary *)params
  withSuccessBlock:(requestSuccessBlock)success
  withFailureBlock:(requestFailureBlock)failure;

/**
 *  POST 请求
 *
 *  @param url     网络请求的 url
 *  @param params  网络请求 参数
 *  @param success 请求成功的回调
 *  @param failure 请求失败的回调
 */
+ (void)postWithURL:(NSString *)url
         withParams:(NSDictionary *)params
   withSuccessBlock:(requestSuccessBlock)success
   withFailureBlock:(requestFailureBlock)failure;

/**
 *  POST 上传图片 请求
 *
 *  @param url     网络请求的 url
 *  @param params  网络请求 参数
 *  @param success 请求成功的回调
 *  @param failure 请求失败的回调
 */

+ (void)postImageWithURL:(NSString *)url
         withParams:(NSDictionary *)params
        withImage:(UIImage *)images
   withSuccessBlock:(requestSuccessBlock)success
   withFailureBlock:(requestFailureBlock)failure;

/**
 *  PATCH 请求
 *
 *  @param url     网络请求的 url
 *  @param params  网络请求 参数
 *  @param success 请求成功的回调
 *  @param failure 请求失败的回调
 */
+ (void)patchWithURL:(NSString *)url
          withParams:(NSDictionary *)params
    withSuccessBlock:(requestSuccessBlock)success
    withFailureBlock:(requestFailureBlock)failure;

/**
 *  DELETE 请求
 *
 *  @param url     网络请求的 url
 *  @param params  网络请求 参数
 *  @param success 请求成功的回调
 *  @param failure 请求失败的回调
 */
+ (void)deleteWithURL:(NSString *)url
           withParams:(NSDictionary *)params
     withSuccessBlock:(requestSuccessBlock)success
     withFailureBlock:(requestFailureBlock)failure;


+ (BOOL)isNetWorkConnecting;

@end
